bitkeeper revision 1.1511 (4291af78wDb78xhg10ccUaCX1vnh_w)
authorcl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Mon, 23 May 2005 10:24:56 +0000 (10:24 +0000)
committercl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Mon, 23 May 2005 10:24:56 +0000 (10:24 +0000)
XendDomain.py, xc.c, xc_linux_restore.c, xc.h:
  Move read of pfn to mfn frame list into xc_linux_restore.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
tools/libxc/xc.h
tools/libxc/xc_linux_restore.c
tools/python/xen/lowlevel/xc/xc.c
tools/python/xen/xend/XendDomain.py

index 99b55f50b508b358070977e48d2ad77d7b67ff04..3c7f7e5564dfa48862333a6e5685b4d850c71044 100644 (file)
@@ -244,8 +244,7 @@ int xc_linux_save(int xc_handle, struct XcIOContext *ioctxt);
  * @parm ioctxt the IO context to restore a domain from
  * @return 0 on success, -1 on failure
  */
-int xc_linux_restore(int xc_handle, int io_fd, u32 dom, unsigned long nr_pfns,
-                    unsigned char *pfn2mfn);
+int xc_linux_restore(int xc_handle, int io_fd, u32 dom, unsigned long nr_pfns);
 
 int xc_linux_build(int xc_handle,
                    u32 domid,
index fe92441511d51c6ac3a961e4a6c00e8af8211cb7..7d6aec28591db6b7284bcdbeec3d82faec3ef3a7 100644 (file)
@@ -32,8 +32,7 @@
 #define PPRINTF(_f, _a...)
 #endif
 
-int xc_linux_restore(int xc_handle, int io_fd, u32 dom, unsigned long nr_pfns,
-                     unsigned char *pfn2mfn)
+int xc_linux_restore(int xc_handle, int io_fd, u32 dom, unsigned long nr_pfns)
 {
     dom0_op_t op;
     int rc = 1, i, n, k;
@@ -60,7 +59,7 @@ int xc_linux_restore(int xc_handle, int io_fd, u32 dom, unsigned long nr_pfns,
     unsigned long *ppage = NULL;
 
     /* A copy of the pfn-to-mfn table frame list. */
-    unsigned long *pfn_to_mfn_frame_list = (void *)pfn2mfn; // [1024];
+    unsigned long pfn_to_mfn_frame_list[1024];
 
     /* A table mapping each PFN to its new MFN. */
     unsigned long *pfn_to_mfn_table = NULL;
@@ -91,6 +90,11 @@ int xc_linux_restore(int xc_handle, int io_fd, u32 dom, unsigned long nr_pfns,
         return 1;
     }
 
+    if (read(io_fd, pfn_to_mfn_frame_list, PAGE_SIZE) != PAGE_SIZE) {
+       ERR("read pfn_to_mfn_frame_list failed");
+       goto out;
+    }
+
     /* We want zeroed memory so use calloc rather than malloc. */
     pfn_to_mfn_table = calloc(4, nr_pfns);
     pfn_type = calloc(4, nr_pfns);    
index b1dff53a87116d5b201bef289a430934b01fc119..9e6396c75bdccdce82908a903014e4775bc0a1b3 100644 (file)
@@ -343,24 +343,14 @@ static PyObject *pyxc_linux_restore(PyObject *self,
     int rc =-1;
     int io_fd, dom;
     unsigned long nr_pfns;
-    char *pfn2mfn;
-    int pfn2mfn_len;
-    PyObject *pfn2mfn_object;
 
-    static char *kwd_list[] = { "fd", "dom", "pfns", "pfn2mfn", NULL };
+    static char *kwd_list[] = { "fd", "dom", "pfns", NULL };
 
-    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iilO", kwd_list,
-                                      &io_fd, &dom, &nr_pfns,
-                                     &pfn2mfn_object) )
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iil", kwd_list,
+                                      &io_fd, &dom, &nr_pfns) )
         goto exit;
 
-    if (PyString_AsStringAndSize(pfn2mfn_object, &pfn2mfn, &pfn2mfn_len))
-       goto exit;
-
-    if (pfn2mfn_len != PAGE_SIZE)
-       goto exit;
-
-    rc = xc_linux_restore(xc->xc_handle, io_fd, dom, nr_pfns, pfn2mfn);
+    rc = xc_linux_restore(xc->xc_handle, io_fd, dom, nr_pfns);
     if ( rc != 0 )
     {
         PyErr_SetFromErrno(xc_error);
@@ -1042,7 +1032,6 @@ static PyMethodDef pyxc_methods[] = {
       "Restore the CPU and memory state of a Linux guest OS.\n"
       " dom        [int]:    Identifier of domain to be restored.\n"
       " pfns       [int]:    Number of pages domain uses.\n"
-      " pfn2mfn    [str]:    String containing the pfn to mfn frame list.\n\n"
       "Returns: [int] new domain identifier on success; -1 on error.\n" },
 
     { "linux_build", 
index 8f2a03b14ff0cb2d7464eb07ab8704d889968243..08a494b00f3966a715b6c0ce784e2785b18ef223 100644 (file)
@@ -363,15 +363,11 @@ class XendDomain:
                 raise XendError(
                     "not a valid guest state file: pfn count out of range")
 
-            pfn_to_mfn_frame_list = fd.read_exact(PAGE_SIZE,
-                "not a valid guest state file: pfn_to_mfn_frame_list read")
-
             # XXXcl hack: fd.tell will sync up the object and
             #             underlying file descriptor
             ignore = fd.tell()
 
-            xc.linux_restore(fd.fileno(), int(dominfo.id), nr_pfns,
-                             pfn_to_mfn_frame_list)
+            xc.linux_restore(fd.fileno(), int(dominfo.id), nr_pfns)
             return dominfo
 
         except IOError, ex: